home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 18 / fpc103.zip / EDITSTUF.SEQ < prev    next >
Text File  |  1988-06-30  |  4KB  |  103 lines

  1. \ EDITSTUF.SEQ  Stuff needed by the editor              by Tom Zimmer
  2.  
  3. only forth also definitions
  4. vocabulary editor
  5. only forth also hidden definitions also
  6.  
  7.   variable tsegb        \ text segment beginning for current file
  8.   variable lseg         \ linelist save segment
  9.   variable dseg         \ delete lines segment
  10.   variable toff
  11.   variable tend
  12.   variable lastline     \ last valid line in file.
  13.  
  14.   variable warncnt      \ warning count, if not enough memory for delete seg
  15.                         \ then tell user so, but only the first time.
  16.  
  17.   variable byte|line    \ flag to tell if we are going to a line in file
  18.                         \ or a byte offset in file.
  19.  
  20.   variable edready      \ ready to edit, we have a file, and can enter
  21.                         \ editor on it, with no problem.
  22.  
  23.   variable renaming     \ are we keeping backup files?
  24.            renaming on
  25.   variable backingup
  26.   variable currentsize  \ size of the current file on disk in
  27.                         \ 128 byte sectors.
  28.  
  29. : seginit       ( --- )
  30.                 defers initstuff
  31.                 0 currentsize !
  32.                 tsegb  off lseg  off dseg off ;
  33.  
  34. ' seginit is initstuff
  35.  
  36.   132   constant mxlln
  37.  4000   constant maxlines
  38.   100   constant maxdline
  39. 65000. 2constant maxD.filesize
  40.     0   constant screenchar        \ A pseudo variable
  41.     0   constant curline           \ A pseudo variable
  42.  
  43. : memabort      ( n1 --- )
  44.                 8 = abort" Could not allocate memory for Editor" ;
  45.  
  46. : tbuf.init     ( --- )         \ Allocate the edit buffers.
  47.                 toff  off tend  off
  48.                 tsegb @ 0=
  49.         if      65536. 16 um/mod nip alloc
  50.                 memabort nip tsegb !                    \ edit buffer  64k
  51.         then    lseg @ 0=
  52.         if      maxlines 2* 16 / 1+ alloc
  53.                 memabort nip lseg !                     \ Line pointer table
  54.         then    dseg @ 0= warncnt @ 0= and
  55.         if      maxdline mxlln * 16 / 1+ alloc 8 =
  56.                 if      dseg off cr >rev
  57.                     ."  Memory Limited, LINE UNDELETE will NOT be available! "
  58.                         >norm beep 1 seconds beep 1 seconds warncnt incr
  59.                 else    nip dseg  !             \ delete buffer
  60.                 then
  61.         then    ;
  62.  
  63. : edinit      ( --- )
  64. \               defers initstuff      \ Add this to initialization list?
  65.                 tbuf.init ;                       \ Allocate the editor
  66.                                                     \ space needed.
  67.  
  68. \ ' edinit is initstuff
  69.  
  70. only forth also definitions hidden also
  71.  
  72. : nobackup      ( --- )
  73.                 backingup off ;
  74.  
  75. ' nobackup alias backupoff
  76.  
  77. : backupon      ( --- )
  78.                 backingup on ;
  79.  
  80. backupon        \ default to auto backup of data
  81.  
  82. : setbackup     ( --- )
  83.                 defers installstuff
  84.                 cr ." ******"
  85.                 backupon
  86. cr ." The editor can be configured to automatically create backup files"
  87. cr ." of your edits, this is more secure than not having backup files,"
  88. cr ." but requires more disk space.  If you are using a FLOPPY based "
  89. cr ." system, you MAY not want backup files created for you."
  90. cr ." Do you want the editor to automatically create backup files?"
  91. cr cr
  92.    ." Press N for NO, any other key for YES ->" key bl or ascii n =
  93.                 if      nobackup
  94.                 then
  95. cr cr tab ." F-PC " >rev ."  WILL " backingup @ 0=
  96.                 if      ." NOT "
  97.                 then    >norm ."  create backup files." ;
  98.  
  99. ' setbackup is installstuff
  100.  
  101. only forth also definitions
  102.  
  103.